﻿using NfsBLL;
using NfsCommon.Util;
using NfsModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MobileWeb.Controllers
{
    public class ExamineController : Controller
    {
        //
        // GET: /Examine/
        public ActionResult Index()
        {
            return View();
        }
        #region PC模糊查询
        public JsonResult query_share(int pageindex, int pagesize, string Name,int state)
        {
            try
            {
                int id = int.Parse(CookieHelper.GetDecodeCookie("nfs_UserId"));
                ShareBLL bll = new ShareBLL();
                List<share> list = bll.GetShareBycondtion(pageindex, pagesize, Name, state, id);
                return Json(new { MessageCode = "0", ShareList = list}, JsonRequestBehavior.AllowGet);
            }
            catch (Exception)
            {

                return Json(new { MessageCode = "200" }, JsonRequestBehavior.AllowGet);

            }

        }
        #endregion
        public ActionResult Info()
        {
            int id = Request["id"] != "" ? int.Parse(Request["id"]) : 0;
            int agency_id = Request["agency_id"] != "" ? int.Parse(Request["agency_id"]) : 0;
            AgencyBLL bll = new AgencyBLL();
            agency model = bll.GetModel(agency_id);
             ViewData["id"] = id;
             return View(model);
        }
        #region 操作审核和放弃
        [HttpPost]
        public JsonResult OpeShare()
        {
            try
            {
                int id = int.Parse(CookieHelper.GetDecodeCookie("nfs_UserId"));
                int sh_id = Request["id"] != "" ? int.Parse(Request["id"]) : 0;
                int agency_id = Request["agency_id"] != "" ? int.Parse(Request["agency_id"]) : 0;
                int state = Request["state"] != "" ? int.Parse(Request["state"]) : 0;
                ShareBLL bll = new ShareBLL();
                share sh = new share {id=sh_id,state=state };
                bool flag = bll.update_Shenhe(sh,agency_id);
               if (flag)
               {
                   return Json(new { MessageCode = "0"}, JsonRequestBehavior.AllowGet);

               }
               else {
                   return Json(new { MessageCode = "100"}, JsonRequestBehavior.AllowGet);

               }
            }
            catch (Exception)
            {

                return Json(new { MessageCode = "200" }, JsonRequestBehavior.AllowGet);

            }

        }
        #endregion
    }
}